package com.lagou.login.controller;

import org.springframework.boot.web.servlet.server.Session;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/")
public class LoginController {


    @RequestMapping(value = "login")
    public String login(HttpServletRequest request, @RequestParam("name") String name , @RequestParam("password") String password){
        if ("admin".equals(name) && "admin123".equals(password)){
            request.getSession().setAttribute("user",name);
            return "success";
        }
        return "error";
    }






}
